﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using Barbar.Colonization.Core.Localization;
using System.Runtime.Serialization;

namespace Barbar.Colonization.Model.RuleSets {
  [XmlType(TypeName = "RawMaterialType", Namespace = Constants.XmlRootNamespace)]
  public class XmlRawMaterialType : XmlEntity, IRawMaterialType, IRulesetDeserialization {
    private string m_NameCode;
    private TranslatorString m_Name;

    public string NameCode {
      get { return m_NameCode; }
      set { m_NameCode = value; }
    }

    public override string ToString() {
      if (m_Name != null)
        return m_Name.ToString();
      return m_NameCode;
    }

    #region IRawMaterialType Members

    TranslatorString IRawMaterialType.Name {
      get { return m_Name; }
    }

    #endregion

    #region IRulesetDeserialization Members

    void IRulesetDeserialization.OnDeserialization(XmlRuleSet ruleSet) {
      m_Name = new TranslatorString(m_NameCode);
    }

    #endregion
  }
}
